package com.group.elmboot.mapper;

import com.group.elmboot.po.Food;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FoodMapper {

	@Select("select * from food where businessId=#{businessId} order by foodId")
    List<Food> listFoodByBusinessId(Integer businessId);
	
	@Select("select * from food where foodId=#{foodId}")
    Food getFoodById(Integer foodId);
	
	@Update("update food set foodName=#{foodName}, foodExplain=#{foodExplain}, foodImg=#{foodImg}, foodPrice=#{foodPrice} "
			+ "where foodId=#{foodId}")
    int updateFoodInfoById(Food food);
	
	@Insert("insert into food(foodName,foodExplain,foodImg,foodPrice,businessId) values(#{foodName},#{foodExplain},#{foodImg},#{foodPrice},#{businessId})")
	@Options(useGeneratedKeys=true,keyProperty="foodId",keyColumn="foodId")
    int insertFoodInfo(Food food);
	
	@Delete("delete from food where foodId=#{foodId}")
    int deleteFoodInfo(Integer foodId);
}
